利用 gnuplot

您所在的位置:网站首页 plplot 动态波形 利用 gnuplot

利用 gnuplot

2023-11-16 01:40| 来源: 网络整理| 查看: 265

这是一篇很早以前写的小文章,最初发表于我的搜狐博客(2008-09-23 22:55),因为自从转移到这里后,sohu 博客就不再维护了,所以把这篇文章也一起挪了过来。

GNUPLOT 是一款功能强大的跨平台的科学数据可视化工具,可以满足大多数的数据显示功能,但是 GNUPLOT 本身没有提供其他语言的接口。虽然我们可以利用操作系统提供的管道(pipe)功能操纵GNUPLOT, 但是这并非是一件非常简单的事情。gnuplot_i 为我们完成这项工作,它提供了一组简单、友好的程序接口,可以让我们轻松的在程序中调用GNUPLOT 完成复杂的图形显示功能。 当前版本的gnuplot_i 包含2个程序文件:   gnuplot_i.c   gnuplot_i.h 安装 gnuplot_i 非常简单,在此不再描述,读者可以直接参考README 文件。 下面是一个最简单的例子:

#include "gnuplot_i.h" int main(int argc, char *argv[]) { gnuplot_ctrl * h ; h = gnuplot_init() ; gnuplot_plot_equation(h, "sin(x)", "Sine wave"); gnuplot_close(h); } gnuplot_init() 用来开启一个GNUPLOT 进程,并返回一个handle。 gnuplot_close(h)用来关闭这个GNUPLOT 进程。 gnuplot_plot_equation()用来显示一个函数。 其他接口函数包括: 1。显示设置函数,包括 gnuplot_setstyle() sets the plotting style of the next plots gnuplot_set_xlabel() sets the X label for the next plots  gnuplot_set_ylabel() sets the Y label for the next plots 例如: gnuplot_setstyle(h, "impulses") ; gnuplot_set_xlabel(h, "my X label") ; gnuplot_set_xlabel(h, "my Y label") ; style 还可以是 line linepoints step 等。 gnuplot_cmd()函数可以向GNUPLOT 发送任何命令。例如: char myfile[] = "/data/file_in.dat" ; int i ; gnuplot_cmd(handle, "plot '%s'", myfile); for (i=0 ; i


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3